package com.zm.common.utils.collection;

import org.apache.poi.ss.formula.functions.T;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 集合工具类
 *
 * @Author: 汪焰
 * @Date: 2020/6/7 22:22
 * version 1.0.0
 **/
public class CollectionsUtils extends org.apache.commons.collections.ListUtils {

//        <dependency>
//            <groupId>commons-collections</groupId>
//            <artifactId>commons-collections</artifactId>
//            <version>3.2.2</version>
//        </dependency>

    public static boolean isBlank(List<?> obj) {
        return null == obj || obj.isEmpty();
    }

    public static boolean isNotBlank(List<?> obj) {
        return null != obj && !obj.isEmpty();
    }

    public static boolean isBlank(Collection<?> obj) {
        return null == obj || obj.isEmpty();
    }

    public static boolean isNotBlank(Collection<?> obj) {
        return null != obj && !obj.isEmpty();
    }

    public static <T> List<T> convert(T[] values) {
        List<T> result = new ArrayList<>(values.length);
        Collections.addAll(result, values);
        return result;
    }

    public static void clear(Collection<?> obj) {
        if (isNotBlank(obj)) {
            obj.clear();
        }
    }
}
